<?php

/**
 * AplusContentApi
 * PHP version 8.3.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Selling Partner API for A+ Content Management.
 *
 * Use the A+ Content API to build applications that help selling partners add rich marketing content to their Amazon product detail pages. Selling partners can use A+ content to share their brand and product story, which helps buyers make informed purchasing decisions. Selling partners use content modules to add images and text.
 *
 * The version of the OpenAPI document: 2020-11-01
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.9.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace SpApi\Api\aplusContent\v2020_11_01;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use SpApi\ApiException;
use SpApi\AuthAndAuth\RestrictedDataTokenSigner;
use SpApi\Configuration;
use SpApi\HeaderSelector;
use SpApi\Model\aplusContent\v2020_11_01\GetContentDocumentResponse;
use SpApi\Model\aplusContent\v2020_11_01\ListContentDocumentAsinRelationsResponse;
use SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentApprovalSubmissionResponse;
use SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentAsinRelationsRequest;
use SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentAsinRelationsResponse;
use SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentRequest;
use SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse;
use SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentSuspendSubmissionResponse;
use SpApi\Model\aplusContent\v2020_11_01\SearchContentDocumentsResponse;
use SpApi\Model\aplusContent\v2020_11_01\SearchContentPublishRecordsResponse;
use SpApi\Model\aplusContent\v2020_11_01\ValidateContentDocumentAsinRelationsResponse;
use SpApi\ObjectSerializer;
use Symfony\Component\RateLimiter\LimiterInterface;
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Component\RateLimiter\Storage\InMemoryStorage;

/**
 * AplusContentApi Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */
class AplusContentApi
{
    public ?LimiterInterface $createContentDocumentRateLimiter;
    public ?LimiterInterface $getContentDocumentRateLimiter;
    public ?LimiterInterface $listContentDocumentAsinRelationsRateLimiter;
    public ?LimiterInterface $postContentDocumentApprovalSubmissionRateLimiter;
    public ?LimiterInterface $postContentDocumentAsinRelationsRateLimiter;
    public ?LimiterInterface $postContentDocumentSuspendSubmissionRateLimiter;
    public ?LimiterInterface $searchContentDocumentsRateLimiter;
    public ?LimiterInterface $searchContentPublishRecordsRateLimiter;
    public ?LimiterInterface $updateContentDocumentRateLimiter;
    public ?LimiterInterface $validateContentDocumentAsinRelationsRateLimiter;
    protected ClientInterface $client;

    protected Configuration $config;

    protected HeaderSelector $headerSelector;

    /**
     * @var int Host index
     */
    protected int $hostIndex;

    private bool $rateLimiterEnabled;
    private InMemoryStorage $rateLimitStorage;

    /**
     * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
     */
    public function __construct(
        Configuration $config,
        ?ClientInterface $client = null,
        ?bool $rateLimiterEnabled = true,
        ?HeaderSelector $selector = null,
        int $hostIndex = 0
    ) {
        $this->config = $config;
        $this->rateLimiterEnabled = $rateLimiterEnabled;

        if ($rateLimiterEnabled) {
            $this->rateLimitStorage = new InMemoryStorage();

            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-createContentDocument'), $this->rateLimitStorage);
            $this->createContentDocumentRateLimiter = $factory->create('AplusContentApi-createContentDocument');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-getContentDocument'), $this->rateLimitStorage);
            $this->getContentDocumentRateLimiter = $factory->create('AplusContentApi-getContentDocument');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-listContentDocumentAsinRelations'), $this->rateLimitStorage);
            $this->listContentDocumentAsinRelationsRateLimiter = $factory->create('AplusContentApi-listContentDocumentAsinRelations');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-postContentDocumentApprovalSubmission'), $this->rateLimitStorage);
            $this->postContentDocumentApprovalSubmissionRateLimiter = $factory->create('AplusContentApi-postContentDocumentApprovalSubmission');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-postContentDocumentAsinRelations'), $this->rateLimitStorage);
            $this->postContentDocumentAsinRelationsRateLimiter = $factory->create('AplusContentApi-postContentDocumentAsinRelations');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-postContentDocumentSuspendSubmission'), $this->rateLimitStorage);
            $this->postContentDocumentSuspendSubmissionRateLimiter = $factory->create('AplusContentApi-postContentDocumentSuspendSubmission');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-searchContentDocuments'), $this->rateLimitStorage);
            $this->searchContentDocumentsRateLimiter = $factory->create('AplusContentApi-searchContentDocuments');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-searchContentPublishRecords'), $this->rateLimitStorage);
            $this->searchContentPublishRecordsRateLimiter = $factory->create('AplusContentApi-searchContentPublishRecords');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-updateContentDocument'), $this->rateLimitStorage);
            $this->updateContentDocumentRateLimiter = $factory->create('AplusContentApi-updateContentDocument');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('AplusContentApi-validateContentDocumentAsinRelations'), $this->rateLimitStorage);
            $this->validateContentDocumentAsinRelationsRateLimiter = $factory->create('AplusContentApi-validateContentDocumentAsinRelations');
        }

        $this->client = $client ?: new Client();
        $this->headerSelector = $selector ?: new HeaderSelector();
        $this->hostIndex = $hostIndex;
    }

    /**
     * Set the host index.
     *
     * @param int $hostIndex Host index (required)
     */
    public function setHostIndex(int $hostIndex): void
    {
        $this->hostIndex = $hostIndex;
    }

    /**
     * Get the host index.
     *
     * @return int Host index
     */
    public function getHostIndex(): int
    {
        return $this->hostIndex;
    }

    public function getConfig(): Configuration
    {
        return $this->config;
    }

    /**
     * Operation createContentDocument.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string                $restrictedDataToken           Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function createContentDocument(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?string $restrictedDataToken = null
    ): PostContentDocumentResponse {
        list($response) = $this->createContentDocumentWithHttpInfo($marketplace_id, $post_content_document_request, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation createContentDocumentWithHttpInfo.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string                $restrictedDataToken           Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function createContentDocumentWithHttpInfo(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->createContentDocumentRequest($marketplace_id, $post_content_document_request);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-createContentDocument');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->createContentDocumentRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation createContentDocumentAsync.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function createContentDocumentAsync(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request
    ): PromiseInterface {
        return $this->createContentDocumentAsyncWithHttpInfo($marketplace_id, $post_content_document_request)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation createContentDocumentAsyncWithHttpInfo.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function createContentDocumentAsyncWithHttpInfo(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse';
        $request = $this->createContentDocumentRequest($marketplace_id, $post_content_document_request);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-createContentDocument');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->createContentDocumentRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'createContentDocument'.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function createContentDocumentRequest(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request
    ): Request {
        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling createContentDocument'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.createContentDocument, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'post_content_document_request' is set
        if (null === $post_content_document_request || (is_array($post_content_document_request) && 0 === count($post_content_document_request))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $post_content_document_request when calling createContentDocument'
            );
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($post_content_document_request)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($post_content_document_request));
            } else {
                $httpBody = $post_content_document_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getContentDocument.
     *
     * @param string      $content_reference_key
     *                                           The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string      $marketplace_id
     *                                           The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string[]    $included_data_set
     *                                           The set of A+ Content data types to include in the response. (required)
     * @param null|string $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getContentDocument(
        string $content_reference_key,
        string $marketplace_id,
        array $included_data_set,
        ?string $restrictedDataToken = null
    ): GetContentDocumentResponse {
        list($response) = $this->getContentDocumentWithHttpInfo($content_reference_key, $marketplace_id, $included_data_set, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getContentDocumentWithHttpInfo.
     *
     * @param string      $content_reference_key
     *                                           The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string      $marketplace_id
     *                                           The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string[]    $included_data_set
     *                                           The set of A+ Content data types to include in the response. (required)
     * @param null|string $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\GetContentDocumentResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getContentDocumentWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        array $included_data_set,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getContentDocumentRequest($content_reference_key, $marketplace_id, $included_data_set);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-getContentDocument');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getContentDocumentRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\GetContentDocumentResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\GetContentDocumentResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\GetContentDocumentResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getContentDocumentAsync.
     *
     * @param string   $content_reference_key
     *                                        The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string   $marketplace_id
     *                                        The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string[] $included_data_set
     *                                        The set of A+ Content data types to include in the response. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function getContentDocumentAsync(
        string $content_reference_key,
        string $marketplace_id,
        array $included_data_set
    ): PromiseInterface {
        return $this->getContentDocumentAsyncWithHttpInfo($content_reference_key, $marketplace_id, $included_data_set)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getContentDocumentAsyncWithHttpInfo.
     *
     * @param string   $content_reference_key
     *                                        The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string   $marketplace_id
     *                                        The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string[] $included_data_set
     *                                        The set of A+ Content data types to include in the response. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function getContentDocumentAsyncWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        array $included_data_set,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\GetContentDocumentResponse';
        $request = $this->getContentDocumentRequest($content_reference_key, $marketplace_id, $included_data_set);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-getContentDocument');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getContentDocumentRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getContentDocument'.
     *
     * @param string   $content_reference_key
     *                                        The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string   $marketplace_id
     *                                        The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string[] $included_data_set
     *                                        The set of A+ Content data types to include in the response. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function getContentDocumentRequest(
        string $content_reference_key,
        string $marketplace_id,
        array $included_data_set
    ): Request {
        // verify the required parameter 'content_reference_key' is set
        if (null === $content_reference_key || (is_array($content_reference_key) && 0 === count($content_reference_key))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $content_reference_key when calling getContentDocument'
            );
        }
        if (strlen($content_reference_key) < 1) {
            throw new \InvalidArgumentException('invalid length for "$content_reference_key" when calling AplusContentApi.getContentDocument, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling getContentDocument'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.getContentDocument, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'included_data_set' is set
        if (null === $included_data_set || (is_array($included_data_set) && 0 === count($included_data_set))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $included_data_set when calling getContentDocument'
            );
        }
        if (count($included_data_set) < 1) {
            throw new \InvalidArgumentException('invalid value for "$included_data_set" when calling AplusContentApi.getContentDocument, number of items must be greater than or equal to 1.');
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $included_data_set,
            'includedDataSet', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $content_reference_key) {
            $resourcePath = str_replace(
                '{contentReferenceKey}',
                ObjectSerializer::toPathValue($content_reference_key),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation listContentDocumentAsinRelations.
     *
     * @param string        $content_reference_key
     *                                             The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string        $marketplace_id
     *                                             The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string[] $included_data_set
     *                                             The set of A+ Content data types to include in the response. If you don&#39;t include this parameter, the operation returns the related ASINs without metadata. (optional)
     * @param null|string[] $asin_set
     *                                             The set of ASINs. (optional)
     * @param null|string   $page_token
     *                                             A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string   $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function listContentDocumentAsinRelations(
        string $content_reference_key,
        string $marketplace_id,
        ?array $included_data_set = null,
        ?array $asin_set = null,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): ListContentDocumentAsinRelationsResponse {
        list($response) = $this->listContentDocumentAsinRelationsWithHttpInfo($content_reference_key, $marketplace_id, $included_data_set, $asin_set, $page_token, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation listContentDocumentAsinRelationsWithHttpInfo.
     *
     * @param string        $content_reference_key
     *                                             The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string        $marketplace_id
     *                                             The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string[] $included_data_set
     *                                             The set of A+ Content data types to include in the response. If you don&#39;t include this parameter, the operation returns the related ASINs without metadata. (optional)
     * @param null|string[] $asin_set
     *                                             The set of ASINs. (optional)
     * @param null|string   $page_token
     *                                             A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string   $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\ListContentDocumentAsinRelationsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function listContentDocumentAsinRelationsWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        ?array $included_data_set = null,
        ?array $asin_set = null,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->listContentDocumentAsinRelationsRequest($content_reference_key, $marketplace_id, $included_data_set, $asin_set, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-listContentDocumentAsinRelations');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->listContentDocumentAsinRelationsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\ListContentDocumentAsinRelationsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\ListContentDocumentAsinRelationsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\ListContentDocumentAsinRelationsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation listContentDocumentAsinRelationsAsync.
     *
     * @param string        $content_reference_key
     *                                             The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string        $marketplace_id
     *                                             The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string[] $included_data_set
     *                                             The set of A+ Content data types to include in the response. If you don&#39;t include this parameter, the operation returns the related ASINs without metadata. (optional)
     * @param null|string[] $asin_set
     *                                             The set of ASINs. (optional)
     * @param null|string   $page_token
     *                                             A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function listContentDocumentAsinRelationsAsync(
        string $content_reference_key,
        string $marketplace_id,
        ?array $included_data_set = null,
        ?array $asin_set = null,
        ?string $page_token = null
    ): PromiseInterface {
        return $this->listContentDocumentAsinRelationsAsyncWithHttpInfo($content_reference_key, $marketplace_id, $included_data_set, $asin_set, $page_token)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation listContentDocumentAsinRelationsAsyncWithHttpInfo.
     *
     * @param string        $content_reference_key
     *                                             The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string        $marketplace_id
     *                                             The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string[] $included_data_set
     *                                             The set of A+ Content data types to include in the response. If you don&#39;t include this parameter, the operation returns the related ASINs without metadata. (optional)
     * @param null|string[] $asin_set
     *                                             The set of ASINs. (optional)
     * @param null|string   $page_token
     *                                             A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function listContentDocumentAsinRelationsAsyncWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        ?array $included_data_set = null,
        ?array $asin_set = null,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\ListContentDocumentAsinRelationsResponse';
        $request = $this->listContentDocumentAsinRelationsRequest($content_reference_key, $marketplace_id, $included_data_set, $asin_set, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-listContentDocumentAsinRelations');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->listContentDocumentAsinRelationsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'listContentDocumentAsinRelations'.
     *
     * @param string        $content_reference_key
     *                                             The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string        $marketplace_id
     *                                             The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string[] $included_data_set
     *                                             The set of A+ Content data types to include in the response. If you don&#39;t include this parameter, the operation returns the related ASINs without metadata. (optional)
     * @param null|string[] $asin_set
     *                                             The set of ASINs. (optional)
     * @param null|string   $page_token
     *                                             A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function listContentDocumentAsinRelationsRequest(
        string $content_reference_key,
        string $marketplace_id,
        ?array $included_data_set = null,
        ?array $asin_set = null,
        ?string $page_token = null
    ): Request {
        // verify the required parameter 'content_reference_key' is set
        if (null === $content_reference_key || (is_array($content_reference_key) && 0 === count($content_reference_key))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $content_reference_key when calling listContentDocumentAsinRelations'
            );
        }
        if (strlen($content_reference_key) < 1) {
            throw new \InvalidArgumentException('invalid length for "$content_reference_key" when calling AplusContentApi.listContentDocumentAsinRelations, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling listContentDocumentAsinRelations'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.listContentDocumentAsinRelations, must be bigger than or equal to 1.');
        }

        if (null !== $included_data_set && count($included_data_set) < 0) {
            throw new \InvalidArgumentException('invalid value for "$included_data_set" when calling AplusContentApi.listContentDocumentAsinRelations, number of items must be greater than or equal to 0.');
        }

        if (null !== $page_token && strlen($page_token) < 1) {
            throw new \InvalidArgumentException('invalid length for "$page_token" when calling AplusContentApi.listContentDocumentAsinRelations, must be bigger than or equal to 1.');
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/asins';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $included_data_set,
            'includedDataSet', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asin_set,
            'asinSet', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $page_token,
            'pageToken', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $content_reference_key) {
            $resourcePath = str_replace(
                '{contentReferenceKey}',
                ObjectSerializer::toPathValue($content_reference_key),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation postContentDocumentApprovalSubmission.
     *
     * @param string      $content_reference_key
     *                                           The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string      $marketplace_id
     *                                           The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentApprovalSubmission(
        string $content_reference_key,
        string $marketplace_id,
        ?string $restrictedDataToken = null
    ): PostContentDocumentApprovalSubmissionResponse {
        list($response) = $this->postContentDocumentApprovalSubmissionWithHttpInfo($content_reference_key, $marketplace_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation postContentDocumentApprovalSubmissionWithHttpInfo.
     *
     * @param string      $content_reference_key
     *                                           The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string      $marketplace_id
     *                                           The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentApprovalSubmissionResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentApprovalSubmissionWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->postContentDocumentApprovalSubmissionRequest($content_reference_key, $marketplace_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-postContentDocumentApprovalSubmission');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->postContentDocumentApprovalSubmissionRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentApprovalSubmissionResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentApprovalSubmissionResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentApprovalSubmissionResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation postContentDocumentApprovalSubmissionAsync.
     *
     * @param string $content_reference_key
     *                                      The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string $marketplace_id
     *                                      The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentApprovalSubmissionAsync(
        string $content_reference_key,
        string $marketplace_id
    ): PromiseInterface {
        return $this->postContentDocumentApprovalSubmissionAsyncWithHttpInfo($content_reference_key, $marketplace_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation postContentDocumentApprovalSubmissionAsyncWithHttpInfo.
     *
     * @param string $content_reference_key
     *                                      The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string $marketplace_id
     *                                      The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentApprovalSubmissionAsyncWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentApprovalSubmissionResponse';
        $request = $this->postContentDocumentApprovalSubmissionRequest($content_reference_key, $marketplace_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-postContentDocumentApprovalSubmission');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->postContentDocumentApprovalSubmissionRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'postContentDocumentApprovalSubmission'.
     *
     * @param string $content_reference_key
     *                                      The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string $marketplace_id
     *                                      The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentApprovalSubmissionRequest(
        string $content_reference_key,
        string $marketplace_id
    ): Request {
        // verify the required parameter 'content_reference_key' is set
        if (null === $content_reference_key || (is_array($content_reference_key) && 0 === count($content_reference_key))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $content_reference_key when calling postContentDocumentApprovalSubmission'
            );
        }
        if (strlen($content_reference_key) < 1) {
            throw new \InvalidArgumentException('invalid length for "$content_reference_key" when calling AplusContentApi.postContentDocumentApprovalSubmission, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling postContentDocumentApprovalSubmission'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.postContentDocumentApprovalSubmission, must be bigger than or equal to 1.');
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/approvalSubmissions';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $content_reference_key) {
            $resourcePath = str_replace(
                '{contentReferenceKey}',
                ObjectSerializer::toPathValue($content_reference_key),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation postContentDocumentAsinRelations.
     *
     * @param string                                  $content_reference_key
     *                                                                                              The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string                                  $marketplace_id
     *                                                                                              The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request
     *                                                                                              The request details for the content document ASIN relations. (required)
     * @param null|string                             $restrictedDataToken                          Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentAsinRelations(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request,
        ?string $restrictedDataToken = null
    ): PostContentDocumentAsinRelationsResponse {
        list($response) = $this->postContentDocumentAsinRelationsWithHttpInfo($content_reference_key, $marketplace_id, $post_content_document_asin_relations_request, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation postContentDocumentAsinRelationsWithHttpInfo.
     *
     * @param string                                  $content_reference_key
     *                                                                                              The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string                                  $marketplace_id
     *                                                                                              The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request
     *                                                                                              The request details for the content document ASIN relations. (required)
     * @param null|string                             $restrictedDataToken                          Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentAsinRelationsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentAsinRelationsWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->postContentDocumentAsinRelationsRequest($content_reference_key, $marketplace_id, $post_content_document_asin_relations_request);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-postContentDocumentAsinRelations');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->postContentDocumentAsinRelationsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentAsinRelationsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentAsinRelationsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentAsinRelationsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation postContentDocumentAsinRelationsAsync.
     *
     * @param string                                  $content_reference_key
     *                                                                                              The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string                                  $marketplace_id
     *                                                                                              The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request
     *                                                                                              The request details for the content document ASIN relations. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentAsinRelationsAsync(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request
    ): PromiseInterface {
        return $this->postContentDocumentAsinRelationsAsyncWithHttpInfo($content_reference_key, $marketplace_id, $post_content_document_asin_relations_request)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation postContentDocumentAsinRelationsAsyncWithHttpInfo.
     *
     * @param string                                  $content_reference_key
     *                                                                                              The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string                                  $marketplace_id
     *                                                                                              The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request
     *                                                                                              The request details for the content document ASIN relations. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentAsinRelationsAsyncWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentAsinRelationsResponse';
        $request = $this->postContentDocumentAsinRelationsRequest($content_reference_key, $marketplace_id, $post_content_document_asin_relations_request);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-postContentDocumentAsinRelations');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->postContentDocumentAsinRelationsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'postContentDocumentAsinRelations'.
     *
     * @param string                                  $content_reference_key
     *                                                                                              The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string                                  $marketplace_id
     *                                                                                              The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request
     *                                                                                              The request details for the content document ASIN relations. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentAsinRelationsRequest(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentAsinRelationsRequest $post_content_document_asin_relations_request
    ): Request {
        // verify the required parameter 'content_reference_key' is set
        if (null === $content_reference_key || (is_array($content_reference_key) && 0 === count($content_reference_key))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $content_reference_key when calling postContentDocumentAsinRelations'
            );
        }
        if (strlen($content_reference_key) < 1) {
            throw new \InvalidArgumentException('invalid length for "$content_reference_key" when calling AplusContentApi.postContentDocumentAsinRelations, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling postContentDocumentAsinRelations'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.postContentDocumentAsinRelations, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'post_content_document_asin_relations_request' is set
        if (null === $post_content_document_asin_relations_request || (is_array($post_content_document_asin_relations_request) && 0 === count($post_content_document_asin_relations_request))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $post_content_document_asin_relations_request when calling postContentDocumentAsinRelations'
            );
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/asins';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $content_reference_key) {
            $resourcePath = str_replace(
                '{contentReferenceKey}',
                ObjectSerializer::toPathValue($content_reference_key),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($post_content_document_asin_relations_request)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($post_content_document_asin_relations_request));
            } else {
                $httpBody = $post_content_document_asin_relations_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation postContentDocumentSuspendSubmission.
     *
     * @param string      $content_reference_key
     *                                           The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string      $marketplace_id
     *                                           The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentSuspendSubmission(
        string $content_reference_key,
        string $marketplace_id,
        ?string $restrictedDataToken = null
    ): PostContentDocumentSuspendSubmissionResponse {
        list($response) = $this->postContentDocumentSuspendSubmissionWithHttpInfo($content_reference_key, $marketplace_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation postContentDocumentSuspendSubmissionWithHttpInfo.
     *
     * @param string      $content_reference_key
     *                                           The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string      $marketplace_id
     *                                           The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentSuspendSubmissionResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentSuspendSubmissionWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->postContentDocumentSuspendSubmissionRequest($content_reference_key, $marketplace_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-postContentDocumentSuspendSubmission');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->postContentDocumentSuspendSubmissionRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentSuspendSubmissionResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentSuspendSubmissionResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentSuspendSubmissionResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation postContentDocumentSuspendSubmissionAsync.
     *
     * @param string $content_reference_key
     *                                      The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string $marketplace_id
     *                                      The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentSuspendSubmissionAsync(
        string $content_reference_key,
        string $marketplace_id
    ): PromiseInterface {
        return $this->postContentDocumentSuspendSubmissionAsyncWithHttpInfo($content_reference_key, $marketplace_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation postContentDocumentSuspendSubmissionAsyncWithHttpInfo.
     *
     * @param string $content_reference_key
     *                                      The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string $marketplace_id
     *                                      The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentSuspendSubmissionAsyncWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentSuspendSubmissionResponse';
        $request = $this->postContentDocumentSuspendSubmissionRequest($content_reference_key, $marketplace_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-postContentDocumentSuspendSubmission');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->postContentDocumentSuspendSubmissionRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'postContentDocumentSuspendSubmission'.
     *
     * @param string $content_reference_key
     *                                      The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ content identifier. (required)
     * @param string $marketplace_id
     *                                      The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     *
     * @throws \InvalidArgumentException
     */
    public function postContentDocumentSuspendSubmissionRequest(
        string $content_reference_key,
        string $marketplace_id
    ): Request {
        // verify the required parameter 'content_reference_key' is set
        if (null === $content_reference_key || (is_array($content_reference_key) && 0 === count($content_reference_key))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $content_reference_key when calling postContentDocumentSuspendSubmission'
            );
        }
        if (strlen($content_reference_key) < 1) {
            throw new \InvalidArgumentException('invalid length for "$content_reference_key" when calling AplusContentApi.postContentDocumentSuspendSubmission, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling postContentDocumentSuspendSubmission'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.postContentDocumentSuspendSubmission, must be bigger than or equal to 1.');
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/suspendSubmissions';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $content_reference_key) {
            $resourcePath = str_replace(
                '{contentReferenceKey}',
                ObjectSerializer::toPathValue($content_reference_key),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation searchContentDocuments.
     *
     * @param string      $marketplace_id
     *                                         The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $page_token
     *                                         A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function searchContentDocuments(
        string $marketplace_id,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): SearchContentDocumentsResponse {
        list($response) = $this->searchContentDocumentsWithHttpInfo($marketplace_id, $page_token, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation searchContentDocumentsWithHttpInfo.
     *
     * @param string      $marketplace_id
     *                                         The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $page_token
     *                                         A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\SearchContentDocumentsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function searchContentDocumentsWithHttpInfo(
        string $marketplace_id,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->searchContentDocumentsRequest($marketplace_id, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-searchContentDocuments');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->searchContentDocumentsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\SearchContentDocumentsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\SearchContentDocumentsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\SearchContentDocumentsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation searchContentDocumentsAsync.
     *
     * @param string      $marketplace_id
     *                                    The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $page_token
     *                                    A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchContentDocumentsAsync(
        string $marketplace_id,
        ?string $page_token = null
    ): PromiseInterface {
        return $this->searchContentDocumentsAsyncWithHttpInfo($marketplace_id, $page_token)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation searchContentDocumentsAsyncWithHttpInfo.
     *
     * @param string      $marketplace_id
     *                                    The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $page_token
     *                                    A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchContentDocumentsAsyncWithHttpInfo(
        string $marketplace_id,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\SearchContentDocumentsResponse';
        $request = $this->searchContentDocumentsRequest($marketplace_id, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-searchContentDocuments');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->searchContentDocumentsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'searchContentDocuments'.
     *
     * @param string      $marketplace_id
     *                                    The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param null|string $page_token
     *                                    A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchContentDocumentsRequest(
        string $marketplace_id,
        ?string $page_token = null
    ): Request {
        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling searchContentDocuments'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.searchContentDocuments, must be bigger than or equal to 1.');
        }

        if (null !== $page_token && strlen($page_token) < 1) {
            throw new \InvalidArgumentException('invalid length for "$page_token" when calling AplusContentApi.searchContentDocuments, must be bigger than or equal to 1.');
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $page_token,
            'pageToken', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation searchContentPublishRecords.
     *
     * @param string      $marketplace_id
     *                                         The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string      $asin
     *                                         The Amazon Standard Identification Number (ASIN) is the unique identifier of a product within a marketplace. (required)
     * @param null|string $page_token
     *                                         A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function searchContentPublishRecords(
        string $marketplace_id,
        string $asin,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): SearchContentPublishRecordsResponse {
        list($response) = $this->searchContentPublishRecordsWithHttpInfo($marketplace_id, $asin, $page_token, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation searchContentPublishRecordsWithHttpInfo.
     *
     * @param string      $marketplace_id
     *                                         The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string      $asin
     *                                         The Amazon Standard Identification Number (ASIN) is the unique identifier of a product within a marketplace. (required)
     * @param null|string $page_token
     *                                         A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\SearchContentPublishRecordsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function searchContentPublishRecordsWithHttpInfo(
        string $marketplace_id,
        string $asin,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->searchContentPublishRecordsRequest($marketplace_id, $asin, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-searchContentPublishRecords');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->searchContentPublishRecordsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\SearchContentPublishRecordsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\SearchContentPublishRecordsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\SearchContentPublishRecordsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation searchContentPublishRecordsAsync.
     *
     * @param string      $marketplace_id
     *                                    The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string      $asin
     *                                    The Amazon Standard Identification Number (ASIN) is the unique identifier of a product within a marketplace. (required)
     * @param null|string $page_token
     *                                    A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchContentPublishRecordsAsync(
        string $marketplace_id,
        string $asin,
        ?string $page_token = null
    ): PromiseInterface {
        return $this->searchContentPublishRecordsAsyncWithHttpInfo($marketplace_id, $asin, $page_token)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation searchContentPublishRecordsAsyncWithHttpInfo.
     *
     * @param string      $marketplace_id
     *                                    The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string      $asin
     *                                    The Amazon Standard Identification Number (ASIN) is the unique identifier of a product within a marketplace. (required)
     * @param null|string $page_token
     *                                    A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchContentPublishRecordsAsyncWithHttpInfo(
        string $marketplace_id,
        string $asin,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\SearchContentPublishRecordsResponse';
        $request = $this->searchContentPublishRecordsRequest($marketplace_id, $asin, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-searchContentPublishRecords');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->searchContentPublishRecordsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'searchContentPublishRecords'.
     *
     * @param string      $marketplace_id
     *                                    The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param string      $asin
     *                                    The Amazon Standard Identification Number (ASIN) is the unique identifier of a product within a marketplace. (required)
     * @param null|string $page_token
     *                                    A token that you use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchContentPublishRecordsRequest(
        string $marketplace_id,
        string $asin,
        ?string $page_token = null
    ): Request {
        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling searchContentPublishRecords'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.searchContentPublishRecords, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'asin' is set
        if (null === $asin || (is_array($asin) && 0 === count($asin))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $asin when calling searchContentPublishRecords'
            );
        }
        if (strlen($asin) < 10) {
            throw new \InvalidArgumentException('invalid length for "$asin" when calling AplusContentApi.searchContentPublishRecords, must be bigger than or equal to 10.');
        }

        if (null !== $page_token && strlen($page_token) < 1) {
            throw new \InvalidArgumentException('invalid length for "$page_token" when calling AplusContentApi.searchContentPublishRecords, must be bigger than or equal to 1.');
        }

        $resourcePath = '/aplus/2020-11-01/contentPublishRecords';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asin,
            'asin', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $page_token,
            'pageToken', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateContentDocument.
     *
     * @param string                     $content_reference_key
     *                                                                  The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string                $restrictedDataToken           Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function updateContentDocument(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?string $restrictedDataToken = null
    ): PostContentDocumentResponse {
        list($response) = $this->updateContentDocumentWithHttpInfo($content_reference_key, $marketplace_id, $post_content_document_request, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation updateContentDocumentWithHttpInfo.
     *
     * @param string                     $content_reference_key
     *                                                                  The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string                $restrictedDataToken           Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function updateContentDocumentWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->updateContentDocumentRequest($content_reference_key, $marketplace_id, $post_content_document_request);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-updateContentDocument');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->updateContentDocumentRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation updateContentDocumentAsync.
     *
     * @param string                     $content_reference_key
     *                                                                  The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function updateContentDocumentAsync(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request
    ): PromiseInterface {
        return $this->updateContentDocumentAsyncWithHttpInfo($content_reference_key, $marketplace_id, $post_content_document_request)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation updateContentDocumentAsyncWithHttpInfo.
     *
     * @param string                     $content_reference_key
     *                                                                  The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function updateContentDocumentAsyncWithHttpInfo(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\PostContentDocumentResponse';
        $request = $this->updateContentDocumentRequest($content_reference_key, $marketplace_id, $post_content_document_request);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-updateContentDocument');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->updateContentDocumentRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'updateContentDocument'.
     *
     * @param string                     $content_reference_key
     *                                                                  The unique reference key for the A+ Content document. A content reference key cannot form a permalink and might change in the future. A content reference key is not guaranteed to match any A+ Content identifier. (required)
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     *
     * @throws \InvalidArgumentException
     */
    public function updateContentDocumentRequest(
        string $content_reference_key,
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request
    ): Request {
        // verify the required parameter 'content_reference_key' is set
        if (null === $content_reference_key || (is_array($content_reference_key) && 0 === count($content_reference_key))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $content_reference_key when calling updateContentDocument'
            );
        }
        if (strlen($content_reference_key) < 1) {
            throw new \InvalidArgumentException('invalid length for "$content_reference_key" when calling AplusContentApi.updateContentDocument, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling updateContentDocument'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.updateContentDocument, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'post_content_document_request' is set
        if (null === $post_content_document_request || (is_array($post_content_document_request) && 0 === count($post_content_document_request))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $post_content_document_request when calling updateContentDocument'
            );
        }

        $resourcePath = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $content_reference_key) {
            $resourcePath = str_replace(
                '{contentReferenceKey}',
                ObjectSerializer::toPathValue($content_reference_key),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($post_content_document_request)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($post_content_document_request));
            } else {
                $httpBody = $post_content_document_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation validateContentDocumentAsinRelations.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string[]              $asin_set
     *                                                                  The set of ASINs. (optional)
     * @param null|string                $restrictedDataToken           Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function validateContentDocumentAsinRelations(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?array $asin_set = null,
        ?string $restrictedDataToken = null
    ): ValidateContentDocumentAsinRelationsResponse {
        list($response) = $this->validateContentDocumentAsinRelationsWithHttpInfo($marketplace_id, $post_content_document_request, $asin_set, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation validateContentDocumentAsinRelationsWithHttpInfo.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string[]              $asin_set
     *                                                                  The set of ASINs. (optional)
     * @param null|string                $restrictedDataToken           Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\aplusContent\v2020_11_01\ValidateContentDocumentAsinRelationsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function validateContentDocumentAsinRelationsWithHttpInfo(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?array $asin_set = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->validateContentDocumentAsinRelationsRequest($marketplace_id, $post_content_document_request, $asin_set);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-validateContentDocumentAsinRelations');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->validateContentDocumentAsinRelationsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\aplusContent\v2020_11_01\ValidateContentDocumentAsinRelationsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\aplusContent\v2020_11_01\ValidateContentDocumentAsinRelationsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\aplusContent\v2020_11_01\ValidateContentDocumentAsinRelationsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\aplusContent\v2020_11_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation validateContentDocumentAsinRelationsAsync.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string[]              $asin_set
     *                                                                  The set of ASINs. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function validateContentDocumentAsinRelationsAsync(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?array $asin_set = null
    ): PromiseInterface {
        return $this->validateContentDocumentAsinRelationsAsyncWithHttpInfo($marketplace_id, $post_content_document_request, $asin_set)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation validateContentDocumentAsinRelationsAsyncWithHttpInfo.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string[]              $asin_set
     *                                                                  The set of ASINs. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function validateContentDocumentAsinRelationsAsyncWithHttpInfo(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?array $asin_set = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\aplusContent\v2020_11_01\ValidateContentDocumentAsinRelationsResponse';
        $request = $this->validateContentDocumentAsinRelationsRequest($marketplace_id, $post_content_document_request, $asin_set);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'AplusContentApi-validateContentDocumentAsinRelations');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->validateContentDocumentAsinRelationsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'validateContentDocumentAsinRelations'.
     *
     * @param string                     $marketplace_id
     *                                                                  The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids). (required)
     * @param PostContentDocumentRequest $post_content_document_request
     *                                                                  The content document request details. (required)
     * @param null|string[]              $asin_set
     *                                                                  The set of ASINs. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function validateContentDocumentAsinRelationsRequest(
        string $marketplace_id,
        PostContentDocumentRequest $post_content_document_request,
        ?array $asin_set = null
    ): Request {
        // verify the required parameter 'marketplace_id' is set
        if (null === $marketplace_id || (is_array($marketplace_id) && 0 === count($marketplace_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_id when calling validateContentDocumentAsinRelations'
            );
        }
        if (strlen($marketplace_id) < 1) {
            throw new \InvalidArgumentException('invalid length for "$marketplace_id" when calling AplusContentApi.validateContentDocumentAsinRelations, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'post_content_document_request' is set
        if (null === $post_content_document_request || (is_array($post_content_document_request) && 0 === count($post_content_document_request))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $post_content_document_request when calling validateContentDocumentAsinRelations'
            );
        }

        $resourcePath = '/aplus/2020-11-01/contentAsinValidations';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_id,
            'marketplaceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asin_set,
            'asinSet', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($post_content_document_request)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($post_content_document_request));
            } else {
                $httpBody = $post_content_document_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Create http client option.
     *
     * @return array of http client options
     *
     * @throws \RuntimeException on file opening failure
     */
    protected function createHttpClientOption(): array
    {
        $options = [];
        if ($this->config->getDebug()) {
            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
            if (!$options[RequestOptions::DEBUG]) {
                throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile());
            }
        }

        return $options;
    }
}
